<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>视频通话</title>
</head>
<body>
<div id="video" style="margin:0 auto;">

    <div id="agora_local" style="float:right;width:210px;height:147px;display:inline-block;">dd</div>
</div>
<script src="/static/js/app/workspace/conversation/AgoraRTCSDK-2.3.1.js"></script>
<script>
    /*
    * AgoraRTC:用于创建客户端 (Client) 和音视频流 (Stream) 对象
    * Client:提供 AgoraRTC 核心功能的 web 客户端对象
    * Stream:通话中的本地或远程音视频流
    * */
//    app Id=d8d208d16c78459bb8b91a6c3e7c33e6
    /*
    * 1.创建音视频对象
    * mode:频道模式   通信模式：rtc  live
    * codec:
    * */
    var appid='d8d208d16c78459bb8b91a6c3e7c33e6';
    var client = AgoraRTC.createClient({mode:'interop'});
    var uid="4234022244";
    /*
    * 2.初始化client对象
    *
    * */
    client.init(appid, function(){
        alert("AgoraRTC client initialized (AgoraRTC 客户端初始化)");
    });
    /*
    * 3.加入频道
    * */
    client.join(null, "webtest", undefined, function(uid){
        alert("用户 " + uid + " 加入频道成功！");
        alert("时间戳: " + Date.now());
    });
    //远程音视频流已订阅回调事件
    client.on('stream-subscribed', function (evt) {
        var stream = evt.stream;
        alert("Subscribe remote stream successfully: " + stream.getId());
        if ($('div#video #agora_remote'+stream.getId()).length === 0) {
            $('div#video').append('<div id="agora_remote'+stream.getId()+'" style="float:left; width:810px;height:607px;display:inline-block;"></div>');
        }
        stream.play('agora_remote' + stream.getId());
    });
    /*
    * 4.创建本地流（创建音视频流对象）
    *
    * */
    var options = {
        streamID: uid,
        audio: true,
        video: true,
        screen: false,
        //chrome extension id
        //extensionId: "minllpmhdgpndnkomcoccfekfegnlikg"
    }
    var localStream = AgoraRTC.createStream(options);
    alert(localStream);
    /*
    * 5.设置本地流Profile   (设置视频属性)
    * */
    localStream.setVideoProfile("480p_4");
    /*
    * 6.初始化本地流（初始化音频对象）
    * */
    localStream.init(function(){
        alert("初始化本地流");
    });
    /*
    // * 7.发布本地流
    // * */
    // client.publish(localStream,function(err){
    //     alert("Publish stream failed", err);
    // });
    /*
    * 8.监听流事件和订阅远端流
    * */
    /*
    * 9.播放音视频流
    * */
    // localStream.play("agora-remote");
</script>
</body>
</html>